home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / zip2obj.zip / BOGEY.PAS next >
Pascal/Delphi Source File  |  1993-04-10  |  3KB  |  121 lines

  1. Program Bogey;
  2. uses XZip, VGABios;
  3.  
  4. {$R-,S-,I-
  5.  
  6.   Demo showing how to use XZIP.  This program displays a picture of
  7.   Humphrey Bogart in VGA mode 13h.
  8.  
  9.   Restrictions:
  10.   ────────────
  11.   - Needs version 6.0 of TP or 1.0 of TPW to compile
  12.   - Requires VGA adapter to run
  13.  
  14.   Usage notes:
  15.   ───────────
  16.   - Convert imploded image of Bogey to an .OBJ file, compile program
  17.     and run it:
  18.          ZIP2OBJ BOGEY BOGEY.BIN BOGEY
  19.          TPC BOGEY
  20.          BOGEY
  21.  
  22.   Written by Wilbert van Leijen, Amsterdam 1991.  }
  23.  
  24. Const
  25.   shades       = 32;      { Bogey comes in 32 shades of gray+border colour }
  26.   DACTable     : Array[0..shades] of RGBType = (
  27.                   (r:20; g:20; b:20), (r:45; g:45; b:45), (r:47; g:47; b:47),
  28.                   (r:51; g:51; b:51), (r:53; g:53; b:53), (r:49; g:49; b:49),
  29.                   (r:55; g:55; b:55), (r:57; g:57; b:57), (r:59; g:59; b:59),
  30.                   (r:61; g:61; b:61), (r:61; g:61; b:63), (r:63; g:63; b:63),
  31.                   (r:59; g:59; b:61), (r:43; g:43; b:43), (r:37; g:37; b:37),
  32.                   (r:33; g:33; b:33), (r:35; g:35; b:35), (r:39; g:39; b:39),
  33.                   (r:28; g:28; b:28), (r:26; g:26; b:26), (r:24; g:24; b:24),
  34.                   (r:22; g:22; b:22), (r:18; g:18; b:18), (r:16; g:16; b:16),
  35.                   (r:12; g:12; b:12), (r:10; g:10; b:10), (r:31; g:31; b:31),
  36.                   (r: 8; g: 8; b: 8), (r:14; g:14; b:14), (r:41; g:41; b:41),
  37.                   (r:20; g:20; b:20), (r:57; g:57; b:59), (r:53; g:53; b:55));
  38. Var
  39.   LastMode     : Byte;
  40.  
  41. { Link in compressed picture of Humphrey Bogart, a.k.a. 'Bogey' }
  42.  
  43. Function BogeySize : Word; Far; External;
  44. Procedure ExplodeBogey(Var buffer); Far; External;
  45. {$L BOGEY.OBJ }
  46.  
  47. Procedure ConWrite(s : String); External;
  48. Procedure ConWriteLn(s : String); External;
  49. {$L CONWRITE.OBJ }
  50.  
  51. { Fade Bogey smoothly out }
  52.  
  53. Procedure DimDisplay; Assembler;
  54.  
  55. ASM
  56.         PUSH   DS
  57.         POP    ES
  58.         MOV    BX, MaxIntensity
  59.  
  60.   { VGA port 3C8h: PEL address register, (colour index, with auto increment)
  61.     VGA port 3C9h: PEL write register (R, G, B) }
  62.  
  63.         CLD
  64. @1:     LEA    SI, DACTable
  65.         MOV    DI, SI
  66.         MOV    CX, 3*(shades+2)
  67.         XOR    AX, AX
  68.         MOV    DX, 3C8h
  69.         OUT    DX, AL
  70.         INC    DX
  71.  
  72.   { Get colour value, decrement it and update the table }
  73.  
  74. @2:     LODSB
  75.         OR     AX, AX
  76.         JZ     @3
  77.         DEC    AX
  78. @3:     STOSB
  79.         OUT    DX, AL
  80.         LOOP   @2
  81.  
  82.   { Delay before next decrement of R, G, B values }
  83.  
  84.         MOV    CX, 30000
  85. @4:     LOOP   @4
  86.         DEC    BX
  87.         OR     BX, BX
  88.         JNZ    @1
  89. end;  { DimDisplay }
  90.  
  91. Begin  { Bogey }
  92.   If VGAStatus = NotVGA Then
  93.     Begin
  94.       ConWriteLn('This program requires a VGA adapter');
  95.       Exit;
  96.     end;
  97.   LastMode := Mem[$0000:$0449];
  98.   ASM
  99.         MOV    AX, 13h                 { Set VGA Mode 13h: 320x200x256 }
  100.         INT    10h
  101.         MOV    AX, 1012h               { Set block of DAC registers }
  102.         MOV    CX, shades+1
  103.         XOR    BX, BX
  104.         PUSH   DS
  105.         POP    ES
  106.         LEA    DX, DACTable
  107.         INT    10h
  108.   end;
  109.   ExplodeBogey(Ptr($A000, $0000)^);
  110.   ASM
  111.         MOV    AX, 0C07h               { Wait for key to be pressed }
  112.         INT    21h
  113.   end;
  114.   DimDisplay;
  115.   ASM
  116.         MOV    AL, [LastMode]          { Set text mode }
  117.         MOV    AH, 0
  118.         INT    10h
  119.   end;
  120. end.  { Bogey }
  121.